import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../model/Friend.dart';
import 'Avatar.dart';

class FriendGroupSection extends StatelessWidget {
  final String group;
  final List<Friend> friends;

  const FriendGroupSection({super.key, required this.group, required this.friends});

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        // 分组标题
        Container(
          width: double.infinity,
          padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
          child: Text(group, style: const TextStyle(fontSize: 12, fontWeight: FontWeight.bold)),
        ),

        // 分组好友
        ListView.separated(
          shrinkWrap: true,
          // ✅ 保证嵌套时不撑开无限高
          physics: const NeverScrollableScrollPhysics(),
          // ✅ 禁用内部滚动
          separatorBuilder: (context, index) => Divider(color: Colors.grey.shade300, height: 0.5, thickness: 0.5, indent: 70, endIndent: 0),
          itemCount: friends.length,
          itemBuilder: (context, index) {
            final friend = friends[index];
            return Container(
              color: Colors.white,
              child: ListTile(
                leading: Avatar(avatar: friend.avator),
                title: Text(friend.notes),
                onTap: () => EasyLoading.showToast(friend.notes),
              ),
            );
          },
        ),
      ],
    );
  }
}
